package com.ruoyi.common.utils;

/**
 * 数据表拆分工具类
 *
 * @author shixiangwen
 */
public class TableSplitUtil {


    /**
     * @param ci
     * @return
     */
    public static String getCiJieshiTable(String ci) {
        long index = getHashCode(ci) % 10;
        return "ci_jieshi_" + index;
    }

    public static String getGuhanyuTable(String text) {
        long index = getHashCode(text) % 10;
        return "guhanyu_" + index;
    }


    public static String getCiSentenceTable(String ci) {
        long index = getHashCode(ci) % 10;
        return "ci_sentence_" + index;
    }

    public static long getHashCode(String str) {
        int h = 0;
        char val[] = str.toCharArray();
        for (int i = 0; i < val.length; i++) {
            h = 31 * h + val[i];
        }
        return Math.abs((long) h);
    }

    public static void main(String[] args) {
        System.out.println(getCiJieshiTable("测试"));
    }
}
